<?php

namespace App\Providers;

use App\Http\Service\DeviceService;
use App\Service\Fdd\FddClient;
use App\Service\Fdd\FddInterface;
use App\Service\Fdd\FddService;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(FddInterface::class, function() {
            return new FddService(new FddClient(env('FDD_APP_ID'), env('FDD_APP_SECRET')));
        });
        $this->app->singleton(DeviceService::class, function() {
            $client = Http::baseUrl(env('TCP_SERVER', 'http://127.0.0.1:9527'))
                ->timeout(60)
                ->withToken(env('TCP_SERVER_TOKEN', 'RIVER'));
            return new DeviceService($client);
        });
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {

    }
}
